 package com.shaozi.nc.manage.observer;

import java.util.Observable;
import java.util.Observer;
import com.shaozi.nc.manage.observer.base.BaseSecretaryObserver;
import com.shaozi.data.mq.business.base.SourceTypeConsts.OA.Approve;
import com.shaozi.data.mq.business.observer.MqTargetObserverBean;

/**
 * 审批观察者 已读：https://shimo.im/doc/BESz6u08M9Ap3Ju7
 * 
 * @author lyx
 *
 */
public class ApproveObserver extends BaseSecretaryObserver implements Observer {

	// 审批已通过/已驳回/处理完(最后一步通过) 6501 ,6502 ,6503，6504,6506
	private static final Integer[] PassOne_Reject_Complete_sourceType = { Approve.PassOne, Approve.Reject,
			Approve.Complete, Approve.New, Approve.ApproverUpdate };
	// 查看审批单 6501,6503,6502,6505,6507
	private static final Integer[] LOOK_CC_sourceType = { Approve.PassOne, Approve.Reject, Approve.Complete,
			Approve.Remove, Approve.CC };

	@Override
	public void update(Observable o, Object arg) {
		if (arg != null) {
			if (arg instanceof MqTargetObserverBean) {
				MqTargetObserverBean mqBean = (MqTargetObserverBean) arg;
				int sourceType = mqBean.getSourceType();
				switch (sourceType) {
				// 审批已通过/已驳回/处理完(最后一步通过)
				case Approve.PassOne:// 审批已通过
				case Approve.Reject:
				case Approve.Complete:
					updateUserRead(sourceType, mqBean, PassOne_Reject_Complete_sourceType);
					break;
				case Approve.LOOK_CC:// 查看审批单
					updateUserRead(sourceType, mqBean, LOOK_CC_sourceType);
					break;
				default:
					break;
				}
			}
		}
	}

}
